import { createApp } from 'vue'
import pinia from '@/stores/index'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import SvgIcon from '@/components/SvgIcon/index.vue'
import 'virtual:svg-icons-register'
import './permission'
import i18n from './i18n/index.js'
import './assets/main.css'
const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 定义 title 指令
app.directive('title', {
  // 当被绑定的元素挂载到 DOM 上时调用
  mounted(el, binding) {
    document.title = binding.value
  },
  // 当绑定的值更新时调用
  updated(el, binding) {
    document.title = binding.value
  },
})

app.use(pinia)
app.use(router)
app.use(ElementPlus)
app.use(i18n)
app.component('SvgIcon', SvgIcon)

app.mount('#app')
